<!DOCTYPE html>

<html lang='en'>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <script src="./lib/react.development16.4.0.js"></script>
    <script src="./lib/react-dom.development16.4.0.js"></script>
    <script src="./lib/babel.min.js"></script>
</head>

<body>
    <div id="app">
    </div>
    <script type="text/babel">
         class MyCom extends React.Component {
            constructor(props) {
               super(props);
               this.getValue = this.getValue.bind(this)
            }
            
            getValue(e)
            {
              let val = e.target.value; 
              alert(val);
            }

            render() {
                // this 指向MyCom组件示例，在原型当中
                // console.log(this);
                return (
                    <div>
                        <h2>渲染组件{this.props.name}</h2>
                        <input ref="myinput" type="text" onChange={this.getValue}/>
                        <button>获取文本框数据</button>
                    </div>
                )
            }
        }
        
        const el = <MyCom name="张三"/>
        ReactDOM.render(
            el,document.getElementById('app')
        );
    </script>
</body>

</html>